package testDemo.TCPTest;

import com.sun.org.apache.xpath.internal.operations.String;

import java.io.*;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;

public class ClinetThread  implements Runnable{
    //客户端
    private Socket s;

    public ClinetThread() throws IOException {
    }

    public ClinetThread(Socket s) throws IOException {
        this.s = s;
    }

    @Override
    public synchronized void run() {
        try{
            //设置读取文件目录
            File file = new File("Client");
            File[] fileList = file.listFiles();
            for(File i:fileList){
                if(i.isDirectory()){

                }else{

                }
                //读取文件
                BufferedInputStream bis = new BufferedInputStream(new FileInputStream(i));
                //上传文件
                BufferedOutputStream bos = new BufferedOutputStream(s.getOutputStream());
                byte[] byt = new byte[1024];
                int line;
                while((line=bis.read(byt))!=-1){
                    bos.write(byt,0,line);
                }
            }
            //发送成功反馈
        }catch(IOException e){
            e.printStackTrace();
        }
    }
}
